<?php
require_once 'common/common.php';
require_once 'common/conn.php';
$result = array();

if (isset($_GET['usercode'])) {
    $usercode = $_GET['usercode'];
}

if (isset($_GET['headId'])) {
    $headId = $_GET['headId'];
}

if (isset($usercode) && isset($headId)) {
    $usercode = trim($usercode);
    $headId = trim($headId);

    $sql = "UPDATE t_device SET headId = '" . $headId . "' WHERE devicecode = '" . $usercode . "'";

    $db = new DBC();

    if ($db->execute($sql)) {
        $result['errorNo'] = "0";
    } else {
        $result['errorNo'] = "1";
    }
} else {
    $result['errorNo'] = "1";
}

echo json_encode($result);
?>
